Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: mark mesa_error with NORETURN (gcc only) #708

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

VincentVanlaer
Copy link
Contributor

This means that the function will never return to its caller. This makes life easier for the optimizer and can prevent spurious maybe-uninitialized warnings.

This change was triggered by warnings in the mtx module about potentially uninitialized variables after allocation. mesa_error was used to terminate MESA if allocate would fail. Inspection of the intermediate representation of GCC showed that it considered execution to continue after mesa_error, which muddied the control flow blocks. To actually trigger a spurious warning, the variable needs to have rank > 1, be declared with pointer, and have unknown size at compile time. This is quite niche, but future changes to warnings & optimizations might change this. At least adding this attribute may make the generated assembly smaller (this was the case for a simple test function).

ifort does not seem to have a similar attribute.

This means that the function will never return to its caller. This makes
life easier for the optimizer and can prevent spurious
maybe-uninitialized warnings.

This change was triggered by warnings in the mtx module about
potentially uninitialized variables after allocation. mesa_error was
used to terminate MESA if allocate would fail. Inspection of the
intermediate representation of GCC showed that it considered execution
to continue after mesa_error, which muddied the control flow blocks. To
actually trigger a spurious warning, the variable needs to have rank >
1, be declared with pointer, and have unknown size at compile time. This
is quite niche, but future changes to warnings & optimizations might
change this. At least adding this attribute may make the generated
assembly smaller (this was the case for a simple test function).

ifort does not seem to have a similar attribute.
@VincentVanlaer
Copy link
Contributor Author

VincentVanlaer commented Aug 9, 2024

Since this seems to fail on older SDK versions and I can't find an easy way to let GCC ignore unknown attributes, feel free to close. I expect the impact of this change to be quite small in any case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant